<%@page pageEncoding = "utf-8" contentType = "text/html;charset=utf-8"%>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>


<table width="100%" cellpadding="10" cellspacing="10">
  <tr style="border-bottom: 1px #f1f1f1 solid;">
    <th>&nbsp;</th>
    <th><a href="leadexecutorui?_action=${action}&orderBy=N&order=${order}&page=${currentPage}${searchAttributes}">#</a></th>
    <th><a href="leadexecutorui?_action=${action}&orderBy=registrationdate&order=${order}&page=${currentPage}${searchAttributes}">Дата регистрации</a></th>
    <th>Текст</th>
    <th>
      <a href="leadexecutorui?_action=${action}&orderBy=status&order=${order}&page=${currentPage}${searchAttributes}">
        <fmt:message key = "request.status"/>
      </a>
    </th>
    <th>&nbsp;</th>
  </tr>

<c:forEach var = "request" items = "${requestsList}">
  <tr style="border-bottom: 1px #f1f1f1 solid;">
    <td>
      <c:forEach var = "i" begin = "1" end = "${request.priority}">
        <img src = "images/priority_item${i}.gif">
      </c:forEach>
    </td>
    <td><c:out value="${request.id}"/></td>
    <td><fmt:formatDate value="${request.registrationDate}" pattern="dd.MM.yyyy HH:mm"/></td>
    <td>
    <c:choose>
     <c:when test='${request.dispatcherText == null}'>
       <c:out value="${request.clientText}"/>
     </c:when>
     <c:otherwise>
       <c:out value="${request.dispatcherText}"/>
     </c:otherwise>
    </c:choose>
    </td>
    
    <td><c:out value="${request.requestStatus.status}"/></td>
    <td>
    <c:choose>
     <c:when test='${request.requestStatus.id == 3}'>
         <a class = "control" href = 'leadexecutorui?_action=requestCommitForm&request_id=${request.id}'>
           Принять/Отменить
         </a>
     </c:when>
     <c:otherwise>
         <a class = "control" href = 'leadexecutorui?_action=requestDetails&request_id=${request.id}&cancelUrl=${uriEncoded}'>
           <fmt:message key = "request.operations.view"/>
         </a>
     </c:otherwise>     
     </c:choose>
    </td>
  </tr>
</c:forEach>

<c:if test="${fn:length(requestsList) == 0}">
  <tr><td colspan = "6" align="center">Список пуст</td></tr>
</c:if>
  
</table>